package main

import (
	"GoodOrder/global"
	"GoodOrder/initialize"
	"GoodOrder/model"
	"context"
)

func main() {
	//请求时如果报错bad request 请设置es中的java_ops内存
	initialize.InitDB()
	initialize.InitEs()
	var order []model.Order
	global.DB.Find(&order)
	for _, g := range order {
		esModel := model.EsOrder{
			ID:          g.ID,
			OrderSnc:    g.OrderSnc,
			UserId:      g.UserId,
			PayType:     g.PayType,
			OrderStatus: g.OrderStatus,
			AmountPrice: g.AmountPrice,
		}
		_, err := global.Es.Index().Index(model.EsOrder{}.GetIndexName()).BodyJson(esModel).Do(context.Background())
		if err != nil {
			panic(err)
		}
	}
}
